#include <SFML/Graphics/RenderWindow.hpp>
#include <nice2d/macros.h>
#include <nice2d/scene.h>
#include <nice2d/background.h>
#include <nice2d/imagedescriptor.h>
#include <nice2d/components/group.h>
#include <nice2d/components/spritestatus.h>
#include <nice2d/components/imagemanager.h>
#include <nice2d/util.h>
#include <nice2d/piece/piece.h>

#define SCENE_WIDTH  900.0f
#define SCENE_HEIGHT 680.0f

#define OFFSET 10

class UnitScene : public Scene
{
public:
    void onInitialed()override
    {
        setSceneBox({0.0f, 0.0f, SCENE_WIDTH, SCENE_HEIGHT});
        setBackground(Background::create("./../data/images/ground3.png", true));

        TextOption opt;
        opt.characterSize = 15;

        for(int i=0;i<6;i++)
        {
            auto piece = std::make_shared<Piece>(opt);
            piece->setHitPoint(3);
            piece->setAttack(2);
            piece->setDefense(5);
            piece->setMovement(4);
            piece->setSpriteColor(sf::Color::Red);
            piece->setCenter(rand()%(int)SCENE_WIDTH,rand()%(int)SCENE_HEIGHT);
            piece->setSize(64,64);
            piece->addPieceIcon("./../data/icon/nato/units/infantry.png");
            piece->addPieceIcon("./../data/icon/nato/sizes/group.png");
            piece->setBackgroundColor(sf::Color::Transparent);
            piece->setTextColor(sf::Color::White);
            addChild(piece);
        }
    }
};

DECLARE_MAIN_FUNCTION_WITH_SCENE(SCENE_WIDTH, SCENE_HEIGHT, "unit13", UnitScene)
